/**
 * props 类型校验
 */
import React, { Component } from 'react'
import PropTypes from 'prop-types';

export default class PropTypesCom extends Component {
  //声明静态属性 限制 props 值的类型
  static propTypes = {
    name: PropTypes.string.isRequired,
    age: PropTypes.number,
    gender: PropTypes.string
  }

  //配置属性的默认值 
  static defaultProps = {
    name: '张三'
  }

  render() {           
    //查看组件标签的属性
    let {name, age, gender} = this.props;

    return (
      <ul>
        <li>姓名: {name}</li>
        <li>性别: {gender}</li>
        <li>年龄: {age}</li>
      </ul>
    )
  }
}
